<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>请假详情</title>
    <link rel="stylesheet" type="text/css" href="css/index.css"/>
</head>
<body>
<jsp:include page="menu.jsp"/>
<div class="index-content">
    <div class="index-content-operation">
        <a class="info-detail">请假详情</a>
        <br>
        <br>
    </div>
    <br>
    <form action="LeaveServlet?action=edit" method="post" onsubmit="return check()">
        <table class="index-content-table-add" style="font-size: 18px;">
            <tr>
                <%--                这里对应的是实体类的属性--%>
                <td>请假编号：<b>${vo.id}</b></td>
            </tr>
            <tr>
                <td>请假事由：<b>${vo.reason}</b></td>
            </tr>

            <tr>
                <%--                这里对应的是实体类的属性--%>
                <td>天数：<b>${vo.days}</b></td>
            </tr>
            <tr>
                <td>课程编号：<b>${vo.courseId}</b></td>
            </tr>

            <tr>
                <%--                这里对应的是实体类的属性--%>
                <td>学号：<b>${vo.studentId}</b></td>
            </tr>
            <tr>
                <td>状态：<b>${vo.status}</b></td>
            </tr>

            <tr>
                <%--                这里对应的是实体类的属性--%>
                <td>请假时间：<b>${vo.applitime}</b></td>
            </tr>

            <tr>
                <%--                这里对应的是实体类的属性--%>
                <td>审核意见：<b>${vo.opinion}</b></td>
            </tr>

            <tr>
                <%--                这里对应的是实体类的属性--%>
                <td>审核时间：<b>${vo.audittime}</b></td>
            </tr>

        </table>
        <br>
        <c:if test="${loginUser.userType == '辅导员'}">
            <button type="button" class="btn btn-pill btn-outline-success btn-sm"
                    onclick="agree('${vo.id}')">同意
            </button>
        </c:if>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <c:if test="${loginUser.userType == '辅导员'}">
            <button type="button" class="btn btn-pill btn-outline-success btn-sm"
                    onclick="refuse('${vo.id}')">拒绝
            </button>
        </c:if>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-pill btn-outline-secondary btn-sm" onclick="javascript:history.back(-1);">
            返回
        </button>
    </form>
</div>
</body>

<script type="text/javascript">
    //提交之前进行检查，如果return false，则不允许提交
    function check() {
        //根据ID获取值
        if (document.getElementById("id").value.trim().length == 0) {
            alert("请假单号称不能为空!");
            return false;
        }
        if (document.getElementById("courseId").value.trim().length == 0) {

            console.log(document.getElementById("courseId").value)
            alert("课程编号不能为空!");
            return false;
        }

        return true;
    }

    function agree(formId) {
        // 通过表单的id进行处理
        console.log(formId)
        window.location.href='LeaveServlet?action=agree&id=${vo.id}'
    }

    function refuse(formId) {
        // 通过表单的id进行处理
        console.log(formId)
        window.location.href='LeaveServlet?action=refuse&id=${vo.id}'
    }
</script>
</html>
